package com.dave.getaway.app.common.util;

import org.apache.dubbo.common.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wangwj
 * @version 1.0
 * @date 2021/12/18
 * @description: TODO
 */

public class ConvertUtil {

    private ConvertUtil() {
    }

    public static Map<String, String> serviceName2Map(String serviceName) {
        String group = Tool.getGroup(serviceName);
        String version = Tool.getVersion(serviceName);
        String interfaze = Tool.getInterface(serviceName);

        Map<String, String> ret = new HashMap<String, String>();
        if (!StringUtils.isEmpty(serviceName)) {
            ret.put(Constants.INTERFACE_KEY, interfaze);
        }
        if (!StringUtils.isEmpty(version)) {
            ret.put(Constants.VERSION_KEY, version);
        }
        if (!StringUtils.isEmpty(group)) {
            ret.put(Constants.GROUP_KEY, group);
        }

        return ret;
    }
}
